package com.zhou.demo.interfaceclass;

import com.squareup.okhttp.Callback;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.zhou.demo.callback.NewsInforExtraCallback;
import com.zhou.demo.callback.NewsInformationCallback;
import com.zhou.demo.url.ZhihuUrl;

import java.io.IOException;

/**
 * Created by 11065 on 2016/8/11.
 */
public class NewsInforExtroConnect implements NewsInfoExtroInterface {

    @Override
    public void getExtroInfo(String id, final NewsInforExtraCallback callback) {
        OkHttpClient client = new OkHttpClient();
        final Request request = new Request.Builder()
                .url(ZhihuUrl.NEWSEXTOR+id)
                .build();

        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Request request, IOException e) {

            }

            @Override
            public void onResponse(Response response) throws IOException {
                callback.onNewInfoExtraSuccess(response.body().string());
            }
        });
    }
}
interface NewsInfoExtroInterface{
    void getExtroInfo(String id, NewsInforExtraCallback newsInformationCallback);
}
